package listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

@WebListener
public class listener implements HttpSessionListener,HttpSessionAttributeListener{
    //public int count=0;

    @Override
    public void attributeAdded(HttpSessionBindingEvent se) {
        //count++;
       // System.out.println("会话属性创建------->"+count);

       // System.out.println(se.getValue());
        userList.addUser((String) se.getValue());
       // System.out.println("当前在线人数为--------->" + userList.getCount());
        //System.out.println("--------------------");
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent se) {
        userList.removeUser((String) se.getValue());
       // System.out.println("当前在线人数为"+userList.getCount());
       // System.out.println("--------------------");
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent se) {
        userList.addUser((String) se.getValue());
        //System.out.println("当前在线人数为---replace------>" + userList.getCount());
       // System.out.println("--------------------");
    }

    @Override
    public void sessionCreated(HttpSessionEvent se) {
       // count++;
       // System.out.println("会话创建------->"+count);
      //  System.out.println(se.getSession().getAttribute("using"));
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {

    }
}
